﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Happy.Examples.OrderManagement.Domain.Orders;
using Happy.Examples.OrderManagement.Domain.Orders.Fakes;

namespace Happy.Examples.OrderManagement.Domain.Test.Orders
{
    internal static class TestHelper
    {
        public static Dictionary<string, CustomerInfo> StubCustomerInfos = new Dictionary<string, CustomerInfo>
        {
            { "Tom", new CustomerInfo("Tom", "广州", "13666666666") },
            { "Jack", new CustomerInfo("Jack", "广州", "13888888888") }
        };

        public static Order CreateOrderInNewState()
        {
            var orderFactory = new OrderFactory(CreateStubOrderCodeGenerator());

            return orderFactory.Create(StubCustomerInfos["Tom"]);
        }

        public static Order CreateOrderInSavedState()
        {
            var order = CreateOrderInNewState();
            order.Save();

            return order;
        }

        public static Order CreateOrderInAuditingState()
        {
            var order = CreateOrderInSavedState();
            order.Submit();

            return order;
        }

        public static Order CreateOrderInAuditedState()
        {
            var order = CreateOrderInAuditingState();
            order.Audit();

            return order;
        }

        private static IOrderCodeGenerator CreateStubOrderCodeGenerator()
        {
            return new StubIOrderCodeGenerator
            {
                NextOrderCode = () => { return "xxx-xxx-xxx"; }
            };
        }
    }
}
